package net.destroyer.game.tetris.core.shape.cube;

import java.awt.Color;

import javax.media.j3d.Appearance;
import javax.media.j3d.PolygonAttributes;
import javax.media.j3d.QuadArray;
import javax.vecmath.Color3f;

import com.sun.j3d.utils.geometry.ColorCube;

public class Cube extends ColorCube {
	public static final int NORMAL = 1;
	public static final int WIRED = 2;
	private static Color3f DEFAULT = new Color3f(Color.GRAY);
	private static Color3f SKELETON = new Color3f(Color.WHITE);
	private QuadArray g;

	public Cube(int type, double scale) {
		super(scale);
		switch (type) {
		case NORMAL:
			g = (QuadArray) getGeometry();
			setColor(DEFAULT);
			break;
		case WIRED:
			g = (QuadArray) getGeometry();
			Appearance app = new Appearance();
			app.setPolygonAttributes(new PolygonAttributes(
							PolygonAttributes.POLYGON_LINE,
							PolygonAttributes.CULL_NONE, 0));
			this.setAppearance(app);
			setColor(SKELETON);
			break;
			
		default:
			break;
		}
	}
	private void setColor(Color3f color) {
		for (int i = 0; i < 24; i++) {
			this.g.setColor(i, color);
		}

	}
}
